package com.manager {
	import flash.display.MovieClip;
	import flash.system.ApplicationDomain;
	import flash.utils.Dictionary;

	public class Resource {
		private static var resource:Resource = null;
		private var dictionary:Dictionary;
		
		public function Resource() {
			dictionary = new Dictionary();
		}
		/**
		 * 
		 * @param str	   设置的domain关键字
		 * @param domain 传入的domain
		 * 
		 */		
		public function setDomain(str:String,domain:ApplicationDomain):void{
			dictionary[str] = domain;
		}
		public static function getInstance():Resource{
			if(resource==null){
				resource = new Resource();
			}
			return resource;
		}
		/**
		 * 获取mc 
		 * @param keyName 设置的domain关键字
		 * @param name	       资源名
		 * @return 
		 * 
		 */		
		public function getMovieClip(keyName:String,name:String):MovieClip{
			var domain:ApplicationDomain = dictionary[keyName];
			var myClass:Class        	 = domain.getDefinition(name) as Class;
			var mc:MovieClip			 = (new myClass()) as MovieClip;
			return mc;
		}
	}
}